package com.evan.designpatterns.observer.refactor;

import com.evan.designpatterns.observer.refactor.event.AllTeacherEvent;
import com.evan.designpatterns.observer.refactor.event.MicEvent;
import com.evan.designpatterns.observer.refactor.event.TomEvent;
import com.evan.designpatterns.observer.refactor.listener.AllTeacher;
import com.evan.designpatterns.observer.refactor.listener.SingleTeacher;
import com.google.common.eventbus.EventBus;

import java.util.Date;

/**
 * @author :liujiapeng01
 * @date :2019-03-19 17:02
 **/
public class Test {


    public static void main(String[] args) {
        EventBus stackoverflow = new EventBus("gper");

        stackoverflow.register(new SingleTeacher());
        stackoverflow.register(new AllTeacher());

        // @全体老师
        Question question = new Question();
        question.setCreator("even");
        question.setDate(new Date());
        question.setInfo("question1@all");

        AllTeacherEvent allTeacherEvent = new AllTeacherEvent(question);
        stackoverflow.post(allTeacherEvent);


        System.out.println("==================================");

        // @tom
        Question question2 = new Question();
        question2.setCreator("even");
        question2.setDate(new Date());
        question2.setInfo("question1@tom");
        stackoverflow.post(new TomEvent(question2));

        System.out.println("==================================");

        // @mic
        Question question3 = new Question();
        question3.setCreator("even");
        question3.setDate(new Date());
        question3.setInfo("question1@mic");
        stackoverflow.post(new MicEvent(question3));

        System.out.println("==================================");
    }
}
